<template>
    <div>
        <el-form :model="ruleForm" ref="ruleForm" label-width="120px" class="demo-ruleForm">
        <div class="container">
            <h4 style="margin-bottom: 20px">{{ruleForm.breedName}}</h4>
            <el-row v-if="!show">
                <el-button type="primary" @click="handleOk">通过</el-button>
                <el-button @click="handleNo">拒绝</el-button>
            </el-row>
            <el-row v-else>
                <el-button :disabled="isDisabled" v-if="isShow">已通过</el-button>
                <el-button :disabled="isDisabled" v-if="isShow1">已拒绝</el-button>
            </el-row>
			<el-row  style="margin-top:20px">
				<el-form-item label="包装批号：">
					    {{ruleForm.batch}}
					</el-form-item>
			</el-row>
            <el-row >
                <el-col :span="12">
					<el-form-item label="产品大类：">
					    {{ruleForm.inventoryType}}
					</el-form-item>
                    
                   <!-- <el-form-item label="分包时间：">
                        {{ruleForm.createTime}}
                    </el-form-item> -->
					<el-form-item label="发药机编码：">
					    {{ruleForm.dispenserCode}}
					</el-form-item>
                    <el-form-item label="生产日期：">
                        {{ruleForm.time}}
                    </el-form-item>
					<el-form-item label="投料量：">
					    {{ruleForm.surNum}}{{ruleForm.totalWeightUnits}}
					</el-form-item>
                   <el-form-item label="分包数量：">
                       {{ruleForm.printNum}}包
                   </el-form-item>
                   
                </el-col>
                <el-col :span="12">
					<el-form-item label="存货代码：">
					    {{ruleForm.inventoryCode}}
					</el-form-item>
                    <el-form-item label="装量：">
                        {{ruleForm.loadingQuantity}}{{ruleForm.loadingUnits}}
                    </el-form-item>
					<el-form-item label="有效期至：">
					    {{ruleForm.deadLine}}
					</el-form-item>
                   
					
                    <el-form-item label="分包时间：">
                        {{ruleForm.createTime}}
                    </el-form-item>
                </el-col>
            </el-row>
        </div>
        <el-form-item class="footerFixed">
            <el-button @click="backPage">返回</el-button>
        </el-form-item>
        </el-form>
    </div>
</template>

<script>
import {print_findById,print_isOk} from "@/request/api";
    export default {
        components: {
        },
        data() {
            return {
                show: false,
                isDisabled: false,
                isShow: false,
                isShow1: false,
                ruleForm: {},
            };
        },
        mounted(){
            this.id = this.$route.query.id
            this.init()
        },
        methods: {
            backPage () {
                this.$router.go(-1);
            },
            init(){
                print_findById(this.id).then((res) =>{
                    this.ruleForm = res.data
                    this.$nextTick(() =>{
                        // 在这里面去获取DOM
                        if (this.ruleForm.type != 0) {
                            this.show = true
                        }
                        if (this.ruleForm.type == 1) {
                            this.isShow = true
                            this.isDisabled = true
                        } else if (this.ruleForm.type == 2) {
                            this.isShow1 = true
                            this.isDisabled = true
                        }
                    })
                })
            },
            handleOk() {
                this.$confirm('此操作将通过该条数据, 是否继续?', '提示', {
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    type: 'warning'
                }).then(() => {
                    print_isOk({
                        id: this.id,
                        type: 1
                    }).then((res) =>{
                        // var index = this.ruleForm.list.indexOf(item)
                        // if (index !== -1) {
                        //     this.ruleForm.list.splice(index, 1)
                        // }
                        this.$notify({
                            title: '操作成功',
                            message: '通过成功',
                            type: 'success'
                        });
                        this.show = true
                        this.isDisabled = true
                        this.isShow = true
                    })
                });
            },
            handleNo() {
                this.$confirm('此操作将拒绝该条数据, 是否继续?', '提示', {
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    type: 'warning'
                }).then(() => {
                    print_isOk({
                        id: this.id,
                        type: 2
                    }).then((res) =>{
                        // var index = this.ruleForm.list.indexOf(item)
                        // if (index !== -1) {
                        //     this.ruleForm.list.splice(index, 1)
                        // }
                        this.$notify({
                            title: '操作成功',
                            message: '已拒绝',
                            type: 'success'
                        });
                        this.show = true
                        this.isDisabled = true
                        this.isShow1 = true
                    })
                });
            }
        }
    }
</script>
<style scoped lang="less">
.el-pagination{
    text-align: center;
}
</style>